function toLowerCamelCase(str) {
  const reg = /(?:(?:^-?)|\-)([A-z])/g
  return str.trim().replace(reg, (match, p1, offset) => {
    if (offset == 0) {
      return p1 ? p1.toLowerCase() : ''
    }
    return p1 ? p1.toUpperCase() : ''
  })
}
console.log(toLowerCamelCase('-web-kit'))
console.log(toLowerCamelCase('web-kit'))
console.log(toLowerCamelCase('Web-kit'))

function toUpperCamelCase(str) {
  const reg = /(?:(?:^-?)|\-)([A-z])/g
  return str.trim().replace(reg, (match, p1) => {
    return p1 ? p1.toUpperCase() : ''
  })
}

console.log(toUpperCamelCase('-web-kit'))
console.log(toUpperCamelCase('web-kit'))
console.log(toUpperCamelCase('Web-kit'))

// 将驼峰转化成中划线

function toKebabCase(str) {
  const reg = /([A-Z])/g
  let ret = str.replace(reg, '-$1').toLowerCase()
  if (ret.startsWith('-')) {
    return ret.slice(1)
  }
  return ret
}

console.log(toKebabCase('webKit'))
console.log(toKebabCase('WebKit'))
